package com.itqf.json;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;

import java.io.IOException;
import java.lang.reflect.Type;
import java.math.BigDecimal;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/10
 * @Time: 下午3:55
 */
public class MySerializer implements ObjectSerializer {
    @Override
    public void write(JSONSerializer jsonSerializer, Object value, Object o1, Type type, int i) throws IOException {
        // Object value  原值
        String  num ="￥"+ BigDecimal.valueOf((Double) value).setScale(2,BigDecimal.ROUND_HALF_UP)+"元";

        jsonSerializer.write(num);//写回客户端
    }
}
